package region;

import java.util.LinkedList;
import java.util.Random;
import simulator.*;

public class Area 
{
    //Necessary variables
    private int numberOfHouses;//
    private int population;//population
    private int housePopulation;//population to one house
    private LinkedList <simulator.House>houseList;//
    private Random random;
    
    /**
     * Constructor to area class
     * @param _numberOfHouses number of houses in the area of simulation
     * @param _population population in the area of simulation
     */
    public Area(int _numberOfHouses, int _population)
    {
        numberOfHouses = _numberOfHouses;
        population = _population;
        houseList = new LinkedList<simulator.House>();
    }//end of Area Constructor
    
    public void RandomHouseGeneration()
    {
        //the average number of residents to the number of houses rounded up
        for(int i = 0; i < numberOfHouses; i++)
        {
            random = new Random();
            
            int temporaryAvarageRate;
            temporaryAvarageRate = population / numberOfHouses;
            System.out.println("temporaryAvarageRate " + temporaryAvarageRate);
            
            if (temporaryAvarageRate == 1)
                temporaryAvarageRate = 2;
            
            housePopulation = random.nextInt(temporaryAvarageRate + 2) + (temporaryAvarageRate);
            System.out.println("housePopulation " + housePopulation);
            
            houseList.add(new House(housePopulation, 100));
            
            population = population - housePopulation;
            System.out.println("Ostavsheesia naselenie " + population);
        }
        
        
    }
    
    public static void main(String [] args)
    {
        Area a = new Area(20, 50);
        
        a.RandomHouseGeneration();
    }
    
}//end of area
